Skip to content

Allow named views and indexing with a subset of a tensor's indices - #266

Merged
mtfishman merged 2 commits into
mainfrom
named-view-partial-indices
Oct 1, 2026
Merged

mtfishman merged 2 commits into
mainfrom
named-view-partial-indices

Conversation

@jack-dunham

Copy link
Copy Markdown
Contributor

Taking views of tensors with a subset of said tensors indices, i.e. view(a, j[2:3]) or a[j => 2:3], used to throw MethodError: no method matching isless(::Int64, ::Nothing). It now slices the array dimensions corresponding to the provided named indices, and keeps the others whole. A scalar named index drops its dimension in the same way that unnamed scalar indexing does.

An index provided that is not in the tensor, or the same index given more than once, now throws NameMismatch. These cases threw the same confusing MethodError before, so it should now also be clearer to users when these invalid inputs are given.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.69%. Comparing base (549611b) to head (31695f6).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #266      +/-   ##
==========================================
+ Coverage   77.62%   77.69%   +0.06%     
==========================================
  Files          30       30              
  Lines        1819     1820       +1     
==========================================
+ Hits         1412     1414       +2     
+ Misses        407      406       -1     
Flag Coverage Δ
docs 25.60% <0.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread test/test_namedtensor_basics.jl Resolved
@mtfishman

Copy link
Copy Markdown
Member

This is clever, I hadn't considered this syntax... I'll merge once tests pass.

@mtfishman
mtfishman enabled auto-merge (squash) October 1, 2026 17:34
@mtfishman
mtfishman merged commit 64f090d into main Oct 1, 2026
23 of 25 checks passed
@mtfishman
mtfishman deleted the named-view-partial-indices branch October 1, 2026 17:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants